package com.hit.sys.modular.config.controller;

import com.hit.core.pojo.response.ResponseData;
import com.hit.core.pojo.response.SuccessResponseData;
import com.hit.sys.modular.config.param.SysConfigParam;
import com.hit.sys.modular.config.service.SysConfigService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class SysConfigController {

    @Resource
    private SysConfigService sysConfigService;

    @GetMapping("/sysConfig/page")
    public ResponseData page(SysConfigParam sysConfigParam){
        return new SuccessResponseData(sysConfigService.page(sysConfigParam));
    }

    @GetMapping("/sysConfig/detail")
    public ResponseData detail(@Validated(SysConfigParam.detail.class) SysConfigParam sysConfigParam){
        return new SuccessResponseData(sysConfigService.detail(sysConfigParam));
    }

    @PostMapping("/sysConfig/add")
    public ResponseData add(@RequestBody @Validated(SysConfigParam.add.class) SysConfigParam sysConfigParam){
        sysConfigService.add(sysConfigParam);
        return new SuccessResponseData();
    }

    @PostMapping("/sysConfig/edit")
    public ResponseData edit(@RequestBody @Validated(SysConfigParam.edit.class) SysConfigParam sysConfigParam){
        sysConfigService.edit(sysConfigParam);
        return new SuccessResponseData();
    }

    @PostMapping("/sysConfig/delete")
    public ResponseData delete(@RequestBody @Validated(SysConfigParam.delete.class) SysConfigParam sysConfigParam){
        sysConfigService.delete(sysConfigParam);
        return new SuccessResponseData();
    }
}
